package com.jinmdz.fmis.mapper.mapper;

import com.jinmdz.fmis.mapper.entity.ChargeItemEntity;
import com.jinmdz.fmis.mapper.mapper.provider.ChargeItemProvider;
import org.apache.ibatis.annotations.*;

import java.util.ArrayList;

/**
 * 费用项目表Mapper
 *
 * @author generator
 * @date 2020-05-15 09:40
 */
public interface ChargeItemMapper {

    /**
     * 增加ChargeItem
     *
     * @param entity 数据实体
     * @return
     * @author generator
     * @date 2020-05-15 09:40
     */
    @InsertProvider(type = ChargeItemProvider.class, method = "insertChargeItem")
    @Options(useGeneratedKeys = true, keyProperty = "entity.id", keyColumn = "id")
    void insertChargeItem(@Param("entity") ChargeItemEntity entity);

    /**
     * 删除ChargeItem
     *
     * @param id             主键
     * @param modifiedUserId 修改用户外键
     * @param version        版本号
     * @return
     * @author generator
     * @date 2020-05-15 09:40
     */
    @Update(" update charge_item set deleted = 1,modified_user_id = #{modifiedUserId},version = unix_timestamp(now()) where id = #{id} and version = #{version} and unmodified = 0 and deleted = 0 ")
    void deletedForChargeItem(@Param("id") Integer id, @Param("modifiedUserId") Integer modifiedUserId, @Param("version") Long version);

    /**
     * 修改ChargeItem
     *
     * @param entity 数据实体
     * @return
     * @author generator
     * @date 2020-05-15 09:40
     */
    @UpdateProvider(type = ChargeItemProvider.class, method = "updateChargeItem")
    void updateChargeItem(@Param("entity") ChargeItemEntity entity);

    /**
     * 查询ChargeItem实体
     *
     * @param id 主键
     * @return ChargeItemEntity
     * @author generator
     * @date 2020-05-15 09:40
     */
    @Select(" select id,deleted,business_code,service_item_id,item_price,item_number,item_unit,item_charge,discount_charge,benefit_charge,reality_charge,charge_time,as_unsettled,as_settled,charge_settle_id,as_business,as_refund,refund_id,random_code,remark,funeral_parlour_code,create_user_id,gmt_create,unmodified,modified_user_id,gmt_modified,version from charge_item where id = #{id} and deleted = 0 limit 1 ")
    ChargeItemEntity getChargeItemById(@Param("id") Integer id);

    /**
     * 查询ChargeItem列表
     *
     * @param entity 数据实体
     * @return ChargeItemEntity
     * @author generator
     * @date 2020-05-15 09:40
     */
    @SelectProvider(type = ChargeItemProvider.class, method = "listChargeItem")
    ArrayList<ChargeItemEntity> listChargeItem(@Param("entity") ChargeItemEntity entity);
}